(function() {
  'use strict';

  angular
    .module('votingBackend')
    .config(routeConfig);

  /** @ngInject */
  function routeConfig($stateProvider, $urlRouterProvider) {
    /*
    var _isLoggedIn = function() {
      var check = false;
      if ($rootScope.currentUser){
        return !check
        console.log('routing sees user logged in') 
      } else {
        return check
        console.log('routing sees user not logged in')
      }
    }
    */

    $stateProvider
    
    .state('login', {
      //abstract: true,
      redirectTo: 'login.new',
      url: '/',
      templateUrl: 'app/login/login.html',
      controller: 'LoginController'
    })


    .state('login.new', {
      url: 'register',
      templateUrl: 'app/login/login-new.html',
      controller: 'LoginController'
    })

    .state('login.exist', {
      url: 'signin',
      templateUrl: 'app/login/login-exist.html',
      controller: 'LoginController'
    })

    .state('dashboard', {
      url: '',
      redirectTo: 'dashboard.base',
      templateUrl: 'app/dashboard/dashboard.html',
      controller: 'DashboardController'
    })

    .state('dashboard.base', {
      url: '/dashboard',
      templateUrl: 'app/dashboard/dashboard-base.html'
    })

    .state('dashboard.settings', {
      url: '/settings',
      templateUrl: 'app/dashboard/dashboard-settings.html'
    })

    .state('dashboard.review', {
      url: '/review',
      redirectTo: 'dashboard.review.view',
      templateUrl: 'app/dashboard/dashboard-review.html'
    })

    .state('dashboard.create', {
      url: '/create',
      templateUrl: 'app/dashboard/dashboard-create.html'
    })

    .state('dashboard.review.view', {
      url: '',
      templateUrl:'app/dashboard/dashboard-review-view.html'
    })

    .state('dashboard.review.edit', {
      url: '',
      templateUrl: 'app/dashboard/dashboard-review-edit.html'
    })

    .state('launchlive', {
      url: '/launch',
      templateUrl: 'app/launch/launch.html'
    })

    .state('launchnormal', {
      url: '/launchnormal',
      templateUrl: 'app/launch/launchnormal.html'
    })

    .state('results', {
      url: '/results',
      redirectTo: 'results.live',
      templateUrl: 'app/results/results.html'
    })

   
    .state('results.live', {
      url: '/live',
      templateUrl: 'app/results/results-live.html'
    })

    .state('results.review', {
      url: '/review',
      templateUrl: 'app/results/results-review.html'
    })

    .state

    /*

      .state('dashboard', {
        url: '/dashboard',
        templateUrl: '/app/dashboard/dashboard.html',
        controller: 'DashboardController',
      });

*/


    $urlRouterProvider
      
    
    .otherwise('/');
  }

})();
